<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="Edit.aspx.cs" Inherits="Fatec.ControleEstoque.Interface.Edit_Pedidos" %>

<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>
<%@ Register src="~/DynamicData/Content/FilterUserControl.ascx" tagname="DynamicFilter" tagprefix="asp" %>
<%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System.Web.UI.WebControls" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

    <h2>Edit entry from table teste <%= table.DisplayName %></h2>

    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="List of validation errors" style="margin-bottom: 19px" />
            
            <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="DetailsView1" Display="None" />

            <asp:DetailsView ID="DetailsView1" runat="server" 
                DataSourceID="DetailsDataSource" DefaultMode="Edit"
                AutoGenerateEditButton="True" OnItemCommand="DetailsView1_ItemCommand" OnItemUpdated="DetailsView1_ItemUpdated"
                CssClass="detailstable" FieldHeaderStyle-CssClass="bold" DataKeyNames="Id" 
                ondatabound="DetailsView1_DataBound" onload="DetailsView1_Load">
                <FieldHeaderStyle CssClass="bold" />
            </asp:DetailsView>

            <br />
         
            <div class="bottomhyperlink">
                <asp:LinkButton ID="LinkButtonInsert" runat="server" onclick="LinkButtonInsert_Click" CausesValidation="False">Inserir Produto</asp:LinkButton>
            </div>
            
            <br />
            

   
        
    <asp:Panel ID="DetailsPanel" runat="server" style="display:block">
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Button id="ButtonShowPopup" runat="server" style="display:none" />
        		<ajx:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
        		    TargetControlID="ButtonShowPopup" PopupControlID="DetailsPanel" 
        		    CancelControlID="LinkButtonCancel" BackgroundCssClass="modalBackground"	/>
            
                <asp:ValidationSummary ID="ValidationSummary2" runat="server" EnableClientScript="true" HeaderText="List of validation errors" ShowMessageBox="true" ShowSummary="false" />
                <asp:DynamicValidator runat="server" ID="DynamicValidator1" ControlToValidate="DetailsView2" Display="None" />

                <asp:DetailsView ID="DetailsView2" runat="server" DataSourceID="EntityDataSource1"
                  CssClass="detailstable" FieldHeaderStyle-CssClass="bold" 
                  OnItemUpdated="OnDetailsViewItemUpdated" 
                    OnItemInserted="OnDetailsViewItemInserted" DataKeyNames="Id">
                    <FieldHeaderStyle CssClass="bold" />
                </asp:DetailsView>
                
                <asp:LinkButton ID="LinkButtonSave" runat="server" onclick="LinkButtonSave_Click">Salvar</asp:LinkButton>
                <asp:LinkButton ID="LinkButtonCancel" runat="server" CausesValidation="False" 
                    onclick="LinkButtonCancel_Click">Cancelar</asp:LinkButton>

              <asp:EntityDataSource ID="EntityDataSource1" runat="server" EnableDelete="True" 
                    EnableInsert="True" EnableUpdate="True" ConnectionString="name=EstoqueEntities" 
                    DefaultContainerName="EstoqueEntities" EntitySetName="Pedido_Produtos" 
                    oninserting="EntityDataSource1_Inserting">
                      
                  
              </asp:EntityDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>    
    
                <asp:EntityDataSource ID="DetailsDataSource" runat="server" EnableUpdate="True" 
                         ConnectionString="name=EstoqueEntities" DefaultContainerName="EstoqueEntities" 
                         EntitySetName="Pedidos" onselecting="DetailsDataSource_Selecting" 
                ondatabinding="DetailsDataSource_DataBinding" 
                onselected="DetailsDataSource_Selected" onupdated="DetailsDataSource_Updated">
                <WhereParameters>
                    <asp:DynamicQueryStringParameter />
                </WhereParameters>
            </asp:EntityDataSource>
 
         </ContentTemplate>
    </asp:UpdatePanel>           
</asp:Content>          
 
